package app.controller.command
{

	import app.model.global.ApplicationModel;
	import app.service.local.SharedObjectServiceInterface;
	
	import com.gaiaframework.api.Gaia;
	import com.gaiaframework.debug.GaiaDebug;
	import com.terralever.util.Enumerator;
	
	import org.robotlegs.mvcs.Command;
	import app.service.event.SharedObjectServiceEvent;

	
	public class SharedObjectCommand extends Command
	{
		[Inject]
		public var appModel:ApplicationModel;

		[Inject]
		public var sharedObjectService:SharedObjectServiceInterface;
		
		[Inject]
		public var event:SharedObjectServiceEvent;
		
		override public function execute():void
		{
			GaiaDebug.log('SharedObjectCommand.execute: ', event.type);
			
			switch(event.type)
			{
				case SharedObjectServiceEvent.INIT_SHARED_OBJECT:
					sharedObjectService.initWithName(ApplicationModel.SHARED_OBJECT_NAME);
					break;
				case SharedObjectServiceEvent.SHARED_OBJECT_INITIALIZED:

					break;
				case SharedObjectServiceEvent.SAVE_VALUE_WITH_KEY:
					sharedObjectService.saveValueWithKey(event.value, event.key);
					break;
				case SharedObjectServiceEvent.CLEAR_VALUE_WITH_KEY:
					sharedObjectService.clearValueWithKey(event.key);
					break;
				case SharedObjectServiceEvent.CLEAR_ALL:
					sharedObjectService.clearAll();
					break;
			}
						
		}
		

		

	}
}